{% extends 'base.html.twig' %}

{% block body_id 'blog_index' %}

{% block main %}
    {% for post in paginator.results %}
        {{ include('blog/_post.html.twig') }}
    {% else %}
        <div class="jumbotron">{{ 'post.no_posts_found'|trans }}</div>
    {% endfor %}

    {% if paginator.hasToPaginate %}

        <div class="navigation text-center">
            <ul class="pagination pagination-lg">
                {% if paginator.hasPreviousPage %}
                    <li class="page-item">
                        <a class="page-link" href="{{ path('blog_index_paginated', {page: paginator.previousPage, tag: tagName}) }}" rel="previous">
                            <twig:ux:icon name="tabler:arrow-left"/> {{ 'paginator.previous'|trans }}
                        </a>
                    </li>
                {% else %}
                    <li class="page-item disabled">
                        <span class="page-link"><twig:ux:icon name="tabler:arrow-left"/> {{ 'paginator.previous'|trans }}</span>
                    </li>
                {% endif %}

                {% for i in 1..paginator.lastPage %}
                    {% if i == paginator.currentPage %}
                        <li class="page-item active">
                            <span class="page-link">{{ i }} <span class="sr-only">{{ 'paginator.current'|trans }}</span></span>
                        </li>
                    {% else %}
                        <li class="page-item"><a class="page-link" href="{{ path('blog_index_paginated', {page: i, tag: tagName}) }}">{{ i }}</a></li>
                    {% endif %}
                {% endfor %}

                {% if paginator.hasNextPage %}
                    <li class="page-item">
                        <a class="page-link" href="{{ path('blog_index_paginated', {page: paginator.nextPage, tag: tagName}) }}">
                            <span>{{ 'paginator.next'|trans }} <twig:ux:icon name="tabler:arrow-right"/></span>
                        </a>
                    </li>
                {% else %}
                    <li class="page-item disabled">
                        <span class="page-link">{{ 'paginator.next'|trans }} <twig:ux:icon name="tabler:arrow-right"/></span>
                    </li>
                {% endif %}
            </ul>
        </div>
    {% endif %}
{% endblock %}

{% block sidebar %}
    {{ parent() }}

    {{ show_source_code(_self) }}
    {{ include('blog/_rss.html.twig') }}
{% endblock %}
